﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style>
        table {
            width: 700px;
            border-collapse: collapse;
            border-spacing: 0;
        }

        tr {
            border: 1px solid #cccccc;
        }

        th, td {
        }
    </style>
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
    <region>

        <form>
            <table>
                <tr>
                    <th colspan="2" style="text-align:center">
                        代码生成器
                    </th>
                </tr>
                <tr>
                    <th style="width:200px;text-align:right">
                        项目名称：
                    </th>
                    <td>
                        <input id="projectName" type="text" value="Nlizard.Message" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align:center">
                        <input id="btnGen" type="button" value="生成" />
                    </td>
                </tr>
            </table>
        </form>
    </region>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnGen").click(function () {
                var projectName = $("#projectName").val();
                $.ajax({
                    url: "codegen/index",
                    data: { projectName: projectName },
                    method: "get",
                    dataType: "json",
                    success: function (data) {
                        if (data.code == 1) {
                            var downloadurl = location.protocol + '//' + location.host + data.url;
                            location.href = downloadurl;
                        }
                        else {
                            alert(data);
                        }
                    }
                });
            });
        });
    </script>
</body>
</html>